home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / apps / 150 / sheet.doc < prev    next >
Text File  |  1988-03-13  |  19KB  |  379 lines

  1. 0660103030566
  2. 1Sheet.DocBy Chor-ming Lung16-Feb, 1988
  3. 2page #
  4. 9[....................................................]
  5. êPreface:Ç
  6.      Ihaveusedspreadsheetforquiteawhile,andIfeltit
  7. isafantastictool.MymostfamiliarspreadsheetisLotus
  8. 123(orVIPprofessional).OnethingthatIfeelterribleis
  9. itsMACROlanguage.Itisnotasuser-friendlyasits
  10. display.IfeelBASICismoresuitablethanMACROfora
  11. spreadsheetlanguage.
  12.  
  13.      So,IthinkthatmaybeprofitabletowriteaBASIC
  14. interpreterinaspreadsheetenvironment.ThefirstthingI
  15. havetodoiscreatingthespreadsheetprogram.
  16.  
  17.      IhadwrittenacalculatorprogramusingPersonal
  18. Pascal.Hence,Icanborrowalotoffunctionsfromthat
  19. program.AfterIfinishedthebook"ATARISTAPPLICATION
  20. PROGRAMMING"byPOLLACKandWEBERfromBANTAM,Ifelt
  21. ifIwantedtotakefulluseofGEM,IhavetoswitchtoC
  22. language.
  23.  
  24.      Tospeeduptheprocessofwritingthespreadsheet,I
  25. wasthinkingtodownloadsomepublicdomainspreadsheet
  26. programsandlearnedfromthemfirst.ThefirstoneItried
  27. isaMODULA-2programwrittenforBYTEmagazine.Tomy
  28. surprise,Icouldnotunderstandthesourcefile.Iknew
  29. thereisanotherpublicdomainspreadsheetprogram--
  30. MICROCAL(fromBorlandforTurboPascal).Thisprogramis
  31. mucheasiertounderstand.Ilearnedwhatisessentialfor
  32. buildingaspreadsheetprogramfromit.
  33.  
  34.      WithMICROCAL,BANTAMbook,andmycalculatorprogram,I
  35. thinkIcanmakearobustspreadsheetveryfast.After3and
  36. halfmonthsstruggle,Ihaveausablespreadsheetrunning
  37. now.
  38.  
  39.      ThespreadsheetisnotdoneyetandtheBASIC
  40. interpreterisstillalongwaytogo.Anyway,Ifeelthe
  41. spreadsheetisquiteusableeveninitsinfantstage.
  42.  
  43.  
  44. êDisclaimerÇ:
  45.      Ihavemadeeveryefforttoinsuretheaccuracyofthe
  46. program.However,thereisnowarrantyeitherexpressor
  47. impliedforitsuses.
  48.  
  49.  
  50. êProgramspecificationÇ:
  51.      SHEET(thenameofthisprogram)iswritteninMark
  52. WilliamsC.Theaccuracyforrealnumber(double)inMark
  53. WilliamsCisupto17digits(Lotus123isupto15digits).
  54. Therangeofcalculationis-1E-37to1E+37.Each
  55. spreadsheetcontains255by1280cellsandthespreadsheetis
  56. implementedbyusingSparseMatrix.(äWhatdoesSparceMatrix
  57. mean?Simplyspeaking,theemptycellswillnotoccupyany
  58. computermemory.So,youcaninsertsomethingincell
  59. "IU1280"withoutrunninginto"NOTENOUGHMEMORY"errorÇ).But
  60. therearesomepeculiareffectsthatisduetoSparseMatrix.
  61. Iwillrefertothislater.Anyinputtoacellwillbe
  62. tokenizedbeforeitisbeinginserted.Currently,onlyone
  63. windowcanbeused.Thefutureversionwillsupportupto4
  64. windows.
  65.  
  66. ê
  67. RequirementsÇ:
  68. *Atari520STor1040STwithdiskdrive(s).
  69. *Monochromeorcolormonitor.
  70. *BothSHEET.PRGandCALC.RSConthesamedirectory.
  71. ê
  72.  
  73. HowtolocateacellÇ:
  74.      IassumeyouknowhowtooperatewithGEM.
  75.  
  76.      Tolocateacell,
  77. -useverticalandhorizontalsliderbarsto
  78. movetothedesireddisplayrange.
  79. -putthemouseoverthedesiredcellandpress
  80. leftbutton.
  81.  
  82.  
  83. êCellinputÇ:
  84.      TheoperationofcellinputissimilartoLotus123.
  85. Anythingyoutypewillbeinsertedintotheeditingbuffer.
  86.      äSpecialkey:Ç
  87.      <Backspace>erasesthelastcharacter.
  88. <Return>terminatesinputandthecellcursor
  89. remainsonthesamecell.
  90. <UParrow>terminatesinputandthecellcursor
  91. moves
  92. onerowupifpossible.
  93. <Downarrow>terminatesinputandthecellcursor
  94. movesonerowdownifpossible.
  95. <Leftarrow>terminatesinputandthecellcursor
  96. movesonecolumnleftifpossible.
  97. <Rightarrow>terminatesinputandthecellcursor
  98. movesonecolumnrightifpossible.
  99. <Shift-arrows>terminatesinputandmovesthecell
  100. cursorinthedirectionyouspecifiedby
  101. page.
  102. äSpecialoperations:Ç
  103. <MOUSE>ifthemousecursorisinsidethedisplay
  104. rangeandifyoupresstheleftbutton,
  105. thecellcoordinatethatthemouseis
  106. overwillbeinsertedintotheediting
  107. buffer.(Sometimes,GEMdetectsthemouse
  108. eventveryfast.Butsometimesitdoes
  109. not.So,ifyouseenothingonthe
  110. editinglinewhenyoupressthemouse
  111. leftbutton,pressitalittlebit
  112. longer.Theproblemmaybecausedbytoo
  113. manyhide_mouse,show_mousecalls.Ifyou
  114. rebootthesystem,itwillalwaysdetect
  115. themouseeventveryfast.)
  116. <Sliders>Youcanchangethedisplayrangeby
  117. movingtheverticalorhorizontalslider
  118. bars.Butexcept<Backspace>,anyspecial
  119. keywillresumethedisplaybacktothe
  120. displayrangebeforeediting.
  121.  
  122. êCelleditingÇ:
  123.      Press<F2>andthecurrentcell'scontentwillbe
  124. insertedintotheeditingbuffer.êTheeditingsessionmustbe
  125. Çêterminatedby<ReturnÇ>.
  126. äSpecialkey:Ç
  127. <Leftarrow>moveonecharacterleftifpossible
  128. <Rightarrow>moveonecharacterrightifpossible
  129. <Shift-leftarrow>movetheeditingcursortotheleftmost
  130. character
  131. <Shift-rightarrow>movetheeditingcursortotherightmost
  132. character
  133. <Insert>toggletheINSERTmode.
  134. <Backspace>Deletethecharacterontheleftsideof
  135. editingcursor.
  136. <Delete>Deletethecharacterontherightsideof
  137. editingcursor.
  138.  
  139.  
  140. êtypeofinputÇ:
  141. (äInputarecase-insensitiveÇ)
  142. üFORMULA:ÇInputstringstartswith"+","-",digits,"("
  143. üSTATEMENT:ÇStringstartswith"!"
  144. üCOMMAND:ÇStringstartswith"@"
  145. üTEXT:ÇStringstartswith"\""orcharacterother
  146. thanaboveleadingcharacter.
  147. äDifferencesbetweentypes:Ç
  148.      Internally,üFORMULAÇwillbeseparatedtoüFORMULAÇor
  149. üCONSTANTÇdependingwhethertheformulareferstoother
  150. cellsorothervariables(Yes,youcanusevariables.
  151. Remember,wewillhaveaBASICinterpreter).Acell
  152. containsüCONSTANTÇwillneverberecalculated.Itshould
  153. speedupthespreadsheetrecalculationtime.
  154. ü     STATEMENTÇistokenizedBASICstatements.Youcan
  155. havemultiplestatementswith":"asseparator.(äRight
  156. now,everyinputSTATEMENTwillbeexecutedbefore
  157. insertingintothecurrentcell.Itshouldnotbeso.
  158. Therearetworeasonsforthat.First,Iwanttotest
  159. eachstatement.Second,IdonothavetheRUNstatement
  160. yetÇ.)Currently,therearejustafewstatementsbeing
  161. implemented:
  162. üSAVEÇ:Thesameaschoosingmenuitem"Save"
  163. üLOADÇ:Thesameaschoosingmenuitem"Load"
  164. ü=(Assigment)Ç:
  165. äcomparethefollowings:Ç
  166. +c1=12Itisalogicaloperation.A
  167. onemeansTRUEandzeromeans
  168. FALSE.
  169. !c1=12Itisastatementthatchanges
  170. thecontentofcell"C1"toa
  171. constantvalue12.
  172. üIFÇ:IFäconditionÇTHENästatementsÇ(ELSE
  173. ästatements)ÇTheELSEstatementis
  174. optional.
  175. üDEFINEÇ:Forusewithuserdefinefunctions.(äIn
  176. thefuture,alltheuserdefined
  177. functionswillbeonafilecall
  178. FORMULA.DEF.Youhavetodefineyour
  179. functionsbeforecallingSHEET.Ç)
  180. äe.g.Ç!definef(x,y)=3*x+4*y
  181. Inanycell,type+f(3,4),youwill
  182. have25asaresult.
  183. üNOTEÇ:-DonotuseüDEFINEÇasCOMMAND.
  184. -Inthecellthefunctionf(x,y)
  185. beingdefined,youwillsee:
  186. DEFINEF(X,Y)=3*PARAM1+4*PARAM2
  187. üYouhavetomanuallychange
  188. PARAMxÇwhenyouwanttochange
  189. itsdefinitionbyusing<F2>.
  190. -Eachfunctioncanhaveatmost
  191. 9andatleastoneparameters.
  192. -Youhavetodefinethe
  193. functionsagaineachtimeyou
  194. loadthespreadsheetin.
  195.      üCOMMANDÇissimilartoüSTATEMENTÇ.Theonlyexception
  196. isitscontentwillnotbestoredinthecurrentcell.
  197. Forsavingsomememory,eachtimeyoudefineafunction,
  198. thepointerofitstokensisbeingpushedintothe
  199. symboltableinsteadofstoringthesametokenstwice.
  200. So,ifyousay"@DEFINEF(X,Y)=3*x+4*y".Afterits
  201. execution,thesymboltablehasapointerthatwillbe
  202. freedbacktotheoperatingsystem.Whatwillhappen?I
  203. donotknow!
  204.  
  205.  
  206. êChangedisplayformatÇ:
  207. äDefaultformat:Ç
  208. üTEXT:Çleftjustified
  209. üSTATEMENT:Çleftjustified
  210. üFORMULAÇ,
  211. üCONSTANT:Çthenumberofdigitsafterthedecimal
  212. pointissix;rightjustifiedof
  213. calculatedresult,ifpossible,ablank
  214. spaceisaddedattherightmostplace.
  215. üWIDTH:Ç9characterspercolumn
  216. êOnlycalculatedresultandcolumnwidthcanbechanged.Ç
  217. üChangecolumnwidth:Ç
  218. -Selectmenuitem"Width"frommenutitle"Sheet"
  219. -Changethecolumncoordinateandcolumnwidthas
  220. desired.
  221. üChangecellformatÇ:
  222. -Selectmenuitem"Reformat"frommenutitle"Sheet"
  223. -Choosetheformat,decimalplaceandrangeofcells
  224. youwanttochange.
  225. -êNOTEÇ:YOUCANONLYREFORMATTHOSECELLSWHICH
  226. EXIST.ThatisbecauseofSparseMatrix.Aftera
  227. cellhasbeencreated,thecellpossesses
  228. attributes.Ifyouformatsomeemptycellsand
  229. insertsomethingintothosecellsafterthat,those
  230. cellsappearasdefault.Itisnotabug.
  231.  
  232.  
  233. êCalculationÇ:
  234. üAccuracyÇ:upto17digits
  235. üRangeÇ:-1E-37to1E+37
  236. üArithmeticoperatorsÇ:
  237. "+","-","*","/","^",MOD
  238. üLogicaloperators:Ç
  239. AND,OR,NOT,"=","<>",">","<",">=","<=",
  240. "=>","=<"
  241. üBuilt-InfunctionsÇ:
  242. äMathÇ:SIN,COS,TAN,ASIN,ACOS,ATAN,LOG
  243. (älogarithmbase10Ç),EXP,LN(älogarithmbaseÇ
  244. äeÇ),ABS,INT(äintegerpartofarealnumberÇ),
  245. FRAC(äfractionpartofarealnumberÇ),SQR,
  246. SQRT,DATE(äcalculatetheJuliandays,3Ç
  247. äparameters,dd,mm,yyÇ),FACT(äfactorialÇ),
  248. RAD_DEG(äradiantodegreeÇ),DEG_RAD(ädegreetoÇ
  249. äradianÇ).
  250. äStatisticsÇ:
  251. AVERAGE,MEDIAN,STD(ästandarddeviationÇ)
  252. äMiscellaneousÇ:
  253. MAX,MIN,SUM
  254.          ä FinanceÇ:
  255.                     NONE.
  256. äStringÇ:
  257. NONE.
  258. üPriorityÇ:
  259. äLowestÇ:-"+","-",OR
  260. -"*","/","^",AND,MOD
  261. -number,cellreference,variable,function
  262. call,NOT,"+","-"(unaryoperator)
  263. äHighestÇ:-Parenthesis
  264. üConstantsÇ:PIä(0.31415926535897932e+01)Ç,TODAYä(Juliandays
  265. whenyoupressTODAY,similartothefunction
  266. @TODAYonVIPprofessional.InLotus123,
  267. @TODAYwillberecalculatewhenyouloadthe
  268. file,butVIPwon't)
  269. Ç
  270. 
  271. êRecalculationÇ:
  272. äRecalculationorders:Ç
  273. üNaturalÇ:Recalculateeachcellintheordertheyare
  274. inserted.Itworkslikefirst-come-first-
  275. serve.
  276. üRow:ÇRecalculateeachrowintheascendingorder.
  277. üColumn:ÇRecalculateeachcolumnintheascending
  278. order.
  279. ♪①äManualrecalculation:Ç
  280.      Thespreadsheetstopsautomaticrecalculation.User
  281. hastopress<ALT-N>,<ALT-R>or<ALT-C>fornatural,
  282. roworcolumnrecalculation,where<ALT-N>meanspress
  283. <Alternate>keywithcharacterkey<N>simultaneously.
  284. äNotes:Ç
  285.      Rowandcolumnrecalculationmethodsarefaster
  286. thannaturalrecalculationmethod.ThatisduetoSparse
  287. Matrix.Eachcellislinkedwithwithitsleft,right,
  288. top,downcellstightly.Fornaturalrecalculation,each
  289. cellhastolocateindividually.Forrowandcolumn
  290. recalculation,eachcellcanmovetoitsnextcellby
  291. usingthelinkedpointer.
  292.  
  293.  
  294. êFileformatÇ:
  295. äHeaderÇ:
  296. -2bytesforversionnumber,currentversionis1.0
  297. -268bytesforprint-dialoginformation(actually,
  298. only262bytesareused.Whenthegraphicpartis
  299. done,thisareawillbeusedforgraphinformation)
  300. -40bytesforwindowtitle.(39characterswitha
  301. nullcharacter)
  302. -2bytesforchecksumofthewindowtitletomake
  303. sureIamhandlingtherightworksheet.
  304. -256bytesforwidthofeachcolumns(youcannot
  305. displaycolumn0,butitisplannedtobeusedby
  306. theBASICinterpreterforinternaloperation).
  307. -2bytesforwindowtype(Itisuseless)
  308. -8bytesforcurrentwindowsize
  309. -4bytesfordisplayrangetoprow,topcolumn
  310. -4bytesforcurrentcellcursoraddress
  311. -2bytesforcurrentrecalculationmode
  312. äCellcontents:Ç
  313. -4bytesforcellrow,column
  314. -2bytesfordisplayattribute
  315. -2bytesfordecimalplace
  316. -2bytesfortokenslength
  317. -8bytesforcalculatedresult
  318. -tokenslengthbytesofactualtokens
  319.  
  320.  
  321. êPrintÇ:
  322.      Youcanprintyourworksheettoafileortoprinter.
  323. Theprintroutinewillprintthose
  324. columnsthatfitsonthemargins.Ifsomecolumnsonthe
  325. printrangearenotprintonthefirstpass,theywillbe
  326. printedonlaterpasses.
  327.  
  328.  
  329. êConclusionÇ:
  330.      Whatisnext?IplantoimplementtheCOPY,MOVEand
  331. ERASEcommandsonnextrelease.Somenewfunctionslike
  332. COLUMNandMATRIXshouldbedonealso.Whatarethey?Here
  333. are2examples:
  334. (äe.g.ÇIfyouhave"Quantity"incolumnBstarting
  335. fromrow1torow20,andyouhave"Price"on
  336. columnConthesamerowrange,andifyou
  337. wanttocalculatesubtotalforeachitem(each
  338. row),inLotus,youwilldothis:
  339. +b1*c1oncellD1
  340.                          copyd1startingfromd2downtod20
  341.  
  342. ButifIfinishtheCOLUMNfunction,youcan
  343. dothisinonelineoncellD1:
  344. COLUMN(d1..d20,b1..b20*c1..c20)
  345. WhatdowegainbyusingCOLUMNfunctioninsteadof
  346. COPY?Speed!ByusingCOPYcommand,youhaveto
  347. recalculateasmanycellsasyoucopyto.Butusing
  348. COLUMNfunction,onlyoneformulawillbe
  349. recalculatedinaloop.Itshouldincreasethe
  350. recalculationperformance.
  351.  
  352. äe.g.ÇMATRIX(a1..b3,a1..b3+d1..e3-3*(f1..g3))
  353. Well,itworkssimilartoCOLUMNfunctionandnot
  354. onlymatrixaddition,subtraction,butalsomatrix
  355. multiplicationandinversewillbefunctioning.If
  356. Ifinishthosefunctions,thenlinearregression
  357. andsimultaneousequationscanbesolvedeasily.
  358. )
  359.  
  360.      Well,thisprogramisnotfinishedyetanditneedsyour
  361. help(commentsandsuggestions)andsupport(êdonationÇ$10).
  362. Myaddressesare:
  363.  
  364.                     Mr.Chor-mingLung
  365.                     33GardenSt#3
  366.                     Boston,MA02114
  367.                     U.S.A.
  368.  
  369. GEnie:LUNG
  370. CompuServe:72740,40
  371.  
  372. IwilllogonGEniemoreoftenthanCompuServe.
  373.  
  374. üP.S.Ç     Iamplanningtowriteasimplifiedversionfordesk
  375. accesory.Anyonewhodonateswillreceiveitwhenitis
  376. done.Ablankdiskwithnameandaddressonlabelis
  377. necessaryforthedeskaccessoryprogram.
  378.  
  379.